<?php
add_action('widgets_init','reedwan_adds125x125_load_widgets');


function reedwan_adds125x125_load_widgets(){
		register_widget("Reedwan_Adds125x125_Widget");
}

class Reedwan_Adds125x125_Widget extends WP_widget{
	
	function Reedwan_Adds125x125_Widget(){
		$widget_ops = array('classname' => 'reedwan_adds125x125_widget', 'description' => 'Adds 125x125 for sidebar widget');

		$control_ops = array('id_base' => 'reedwan_adds125x125_widget');

		$this->WP_Widget('reedwan_adds125x125_widget', 'Adds 125x125', $widget_ops, $control_ops);
		
	}
	
	function widget($args,$instance){
		extract($args);
		echo $before_widget;
		$link1 = $instance['link1'];
		$image1 = $instance['image1'];
		$code1 = $instance['code1'];
		
		$link2 = $instance['link2'];
		$image2 = $instance['image2'];
		$code2 = $instance['code2'];
		
		$link3 = $instance['link3'];
		$image3 = $instance['image3'];
		$code3 = $instance['code3'];
		
		$link4 = $instance['link4'];
		$image4 = $instance['image4'];
		$code4 = $instance['code4'];
		
		$link5 = $instance['link5'];
		$image5 = $instance['image5'];
		$code5 = $instance['code5'];
		
		$link6 = $instance['link6'];
		$image6 = $instance['image6'];
		$code6 = $instance['code6'];
		
		$link7 = $instance['link7'];
		$image7 = $instance['image7'];
		$code7 = $instance['code7'];
		
		$link8 = $instance['link8'];
		$image8 = $instance['image8'];
		$code8 = $instance['code8'];
		?>
		<?php
		if($link1 || $image1 || $code1){
		if($image1) {	
		?>				
			<div class="adds125x125"><a href="<?php echo $link1; ?>"><img src="<?php echo $image1; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125"><?php echo stripslashes($code1); ?></div>
		<?php }} ?>
		
		
		<?php
		if($link2 || $image2 || $code2){
		if($image2) {	
		?>				
			<div class="adds125x125 two"><a href="<?php echo $link2; ?>"><img src="<?php echo $image2; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125 two"><?php echo stripslashes($code2); ?></div>
		<?php }} ?>
		
		<?php
		if($link3 || $image3 || $code3){
		if($image3) {	
		?>				
			<div class="adds125x125"><a href="<?php echo $link3; ?>"><img src="<?php echo $image3; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125"><?php echo stripslashes($code3); ?></div>
		<?php }} ?>
		
		<?php
		if($link4 || $image4 || $code4){
		if($image4) {	
		?>				
			<div class="adds125x125 two"><a href="<?php echo $link4; ?>"><img src="<?php echo $image4; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125 two"><?php echo stripslashes($code4); ?></div>
		<?php }} ?>
		
		<?php
		if($link5 || $image5 || $code5){
		if($image5) {	
		?>				
			<div class="adds125x125"><a href="<?php echo $link5; ?>"><img src="<?php echo $image5; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125"><?php echo stripslashes($code5); ?></div>
		<?php }} ?>
		
		<?php
		if($link6 || $image6 || $code6){
		if($image6) {	
		?>				
			<div class="adds125x125 two"><a href="<?php echo $link6; ?>"><img src="<?php echo $image6; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125 two"><?php echo stripslashes($code6); ?></div>
		<?php }} ?>
		
		<?php
		if($link7 || $image7 || $code7){
		if($image7) {	
		?>				
			<div class="adds125x125"><a href="<?php echo $link7; ?>"><img src="<?php echo $image7; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125"><?php echo stripslashes($code7); ?></div>
		<?php }} ?>
		
		<?php
		if($link8 || $image8 || $code8){
		if($image8) {	
		?>				
			<div class="adds125x125 two last"><a href="<?php echo $link8; ?>"><img src="<?php echo $image8; ?>"/></a></div>
		<?php
		}
		else {
		?>
			<div class="adds125x125 two last"><?php echo stripslashes($code8); ?></div>
		<?php }} ?>
		
		
		
		<?php
		echo $after_widget;
	}
	
	function update($new_instance, $old_instance){
		$instance = $old_instance;
		
		$instance['link1'] = $new_instance['link1'];
		$instance['image1'] = $new_instance['image1'];
		$instance['code1'] = $new_instance['code1'];
		
		$instance['link2'] = $new_instance['link2'];
		$instance['image2'] = $new_instance['image2'];
		$instance['code2'] = $new_instance['code2'];
		
		$instance['link3'] = $new_instance['link3'];
		$instance['image3'] = $new_instance['image3'];
		$instance['code3'] = $new_instance['code3'];
		
		$instance['link4'] = $new_instance['link4'];
		$instance['image4'] = $new_instance['image4'];
		$instance['code4'] = $new_instance['code4'];
		
		$instance['link5'] = $new_instance['link5'];
		$instance['image5'] = $new_instance['image5'];
		$instance['code5'] = $new_instance['code5'];
		
		$instance['link6'] = $new_instance['link6'];
		$instance['image6'] = $new_instance['image6'];
		$instance['code6'] = $new_instance['code6'];
		
		$instance['link7'] = $new_instance['link7'];
		$instance['image7'] = $new_instance['image7'];
		$instance['code7'] = $new_instance['code7'];
		
		$instance['link8'] = $new_instance['link8'];
		$instance['image8'] = $new_instance['image8'];
		$instance['code8'] = $new_instance['code8'];
		
		return $instance;
	}
	
	function form($instance){
		$defaults = array('link1' => '', 'image1' => '', 'code1' => '','link2' => '', 'image2' => '', 'code2' => '','link3' => '', 'image3' => '', 'code3' => '','link4' => '', 'image4' => '', 'code4' => '','link5' => '', 'image5' => '', 'code5' => '','link6' => '', 'image6' => '', 'code6' => '','link7' => '', 'image7' => '', 'code7' => '','link8' => '', 'image8' => '', 'code8' => '');
		$instance = wp_parse_args((array) $instance, $defaults); ?>
		<h2>Add 1 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link1'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link1'); ?>" name="<?php echo $this->get_field_name('link1'); ?>" value="<?php echo $instance['link1']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image1'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image1'); ?>" name="<?php echo $this->get_field_name('image1'); ?>" value="<?php echo $instance['image1']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code1'); ?>" name="<?php echo $this->get_field_name('code1'); ?>"><?php echo $instance['code1']; ?></textarea>
		</p>
		
		<h2>Add 2 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link2'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link2'); ?>" name="<?php echo $this->get_field_name('link2'); ?>" value="<?php echo $instance['link2']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image2'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image2'); ?>" name="<?php echo $this->get_field_name('image2'); ?>" value="<?php echo $instance['image2']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code2'); ?>" name="<?php echo $this->get_field_name('code2'); ?>"><?php echo $instance['code2']; ?></textarea>
		</p>
		
		<h2>Add 3 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link3'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link3'); ?>" name="<?php echo $this->get_field_name('link3'); ?>" value="<?php echo $instance['link3']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image3'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image3'); ?>" name="<?php echo $this->get_field_name('image3'); ?>" value="<?php echo $instance['image3']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code3'); ?>" name="<?php echo $this->get_field_name('code3'); ?>"><?php echo $instance['code3']; ?></textarea>
		</p>
		
		<h2>Add 4 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link4'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link4'); ?>" name="<?php echo $this->get_field_name('link4'); ?>" value="<?php echo $instance['link4']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image4'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image4'); ?>" name="<?php echo $this->get_field_name('image4'); ?>" value="<?php echo $instance['image4']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code4'); ?>" name="<?php echo $this->get_field_name('code4'); ?>"><?php echo $instance['code4']; ?></textarea>
		</p>
		
		<h2>Add 5 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link5'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link5'); ?>" name="<?php echo $this->get_field_name('link5'); ?>" value="<?php echo $instance['link5']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image5'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image5'); ?>" name="<?php echo $this->get_field_name('image5'); ?>" value="<?php echo $instance['image5']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code5'); ?>" name="<?php echo $this->get_field_name('code5'); ?>"><?php echo $instance['code5']; ?></textarea>
		</p>
		
		<h2>Add 6 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link6'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link6'); ?>" name="<?php echo $this->get_field_name('link6'); ?>" value="<?php echo $instance['link6']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image6'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image6'); ?>" name="<?php echo $this->get_field_name('image6'); ?>" value="<?php echo $instance['image6']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code6'); ?>" name="<?php echo $this->get_field_name('code6'); ?>"><?php echo $instance['code6']; ?></textarea>
		</p>
		
		<h2>Add 7 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link7'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link7'); ?>" name="<?php echo $this->get_field_name('link7'); ?>" value="<?php echo $instance['link7']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image7'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image7'); ?>" name="<?php echo $this->get_field_name('image7'); ?>" value="<?php echo $instance['image7']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code7'); ?>" name="<?php echo $this->get_field_name('code7'); ?>"><?php echo $instance['code7']; ?></textarea>
		</p>
		
		<h2>Add 8 </h2>
		<h4>Using Image </h4>
		<p>
			<label for="<?php echo $this->get_field_id('link8'); ?>">Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('link8'); ?>" name="<?php echo $this->get_field_name('link8'); ?>" value="<?php echo $instance['link8']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image8'); ?>">Image Url:</label>
			<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('image8'); ?>" name="<?php echo $this->get_field_name('image8'); ?>" value="<?php echo $instance['image8']; ?>" />
		</p>
		<h4 style='margin-top: 20px;'>Or Using Code</h4>
		<p>
			<textarea class="widefat" rows="5" cols="10" id="<?php echo $this->get_field_id('code8'); ?>" name="<?php echo $this->get_field_name('code8'); ?>"><?php echo $instance['code2']; ?></textarea>
		</p>
		<?php

	}
}
?>